Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-get

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-get

Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.

  • 2.8.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.6M
decreased by-41.09%
Maintainers
2
Weekly downloads
 
Created

What is simple-get?

The simple-get npm package is designed to provide a straightforward way to make HTTP requests in Node.js. It is built to be minimalistic but flexible, allowing users to perform GET, POST, and other HTTP methods with ease. It supports features like redirects, streaming, and simple error handling.

What are simple-get's main functionalities?

GET Request

This code sample demonstrates how to perform a simple GET request to a specified URL and stream the response to stdout. It also shows basic error handling.

const get = require('simple-get')

get('http://example.com', function (err, res) {
  if (err) throw err
  console.log(res.statusCode) // 200
  res.pipe(process.stdout) // Stream the response to stdout
})

POST Request

This example illustrates how to send a POST request with a body of data. It demonstrates setting options for the request, including the URL, method, and body.

const get = require('simple-get')

const opts = {
  url: 'http://example.com',
  body: 'some data',
  method: 'POST'
}

get(opts, function (err, res) {
  if (err) throw err
  console.log(res.statusCode) // 200
  res.pipe(process.stdout) // Stream the response to stdout
})

Handling Redirects

This snippet shows how to handle redirects automatically by setting the 'followRedirects' option to true. It makes a request and follows any redirects, eventually logging the response status code of the final URL.

const get = require('simple-get')

get({ url: 'http://example.com', followRedirects: true }, function (err, res) {
  if (err) throw err
  console.log('Response from final URL:', res.statusCode)
  res.pipe(process.stdout)
})

Other packages similar to simple-get

Keywords

FAQs

Package last updated on 02 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc